package com.example.back.controller;

import com.example.back.model.AreaDetails;
import com.example.back.model.Post;
import com.example.back.service.AreaDetailsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author : 贾媛晴
 * @createTime : 2022/4/26 13:45
 */
@RestController
@Api(tags = "AreaDetailsController")
@CrossOrigin //允许跨域
public class AreaDetailsController {

    @Autowired
    public AreaDetailsService areaDetailsService;

    @GetMapping("/AreaDetails")
    public List<AreaDetails> selectAll (){
        List<AreaDetails> areaDetailsList = this.areaDetailsService.selectAll();
        return areaDetailsList;
    }
    // 取出 详情页 的数据
    @GetMapping("/AreaDetails_Detail")
    public AreaDetails selectDetail(String itemId){
        AreaDetails detail=this.areaDetailsService.selectDetail(itemId);
        return detail;
    }

    //    搜索
    @GetMapping("/AreaDetails_search")
    public List<AreaDetails> search(String searchContent){
        List<AreaDetails> serch = this.areaDetailsService.search(searchContent);
        return serch;
    }

    @ApiOperation("查询收藏的景点")
    @GetMapping("/Collection_areaDetails")

    public AreaDetails selectArea(String areaname) {
        return this.areaDetailsService.selectArea(areaname);
    }

    @ApiOperation("后台编辑景区信息")
    @PostMapping("/Edit _areaDetails")
    public int updateArea(int id, String name,String placedes,double ticket){
        return this.areaDetailsService.updateArea(id,name,placedes,ticket);
    }

    @ApiOperation("后台删除景区信息")
    @GetMapping("/Delete_areaDetails")

    public int deleteArea(int id) {
        return this.areaDetailsService.deleteArea(id);
    }

    @ApiOperation("后台添加景区信息")
    @GetMapping("/Insert_areaDetails")
    public int insertArea(String name, String placedes, double ticket) {
        return this.areaDetailsService.insertArea(name,placedes,ticket);
    }
}
